﻿using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Core.Filters;
using Magicodes.ExporterAndImporter.Core.Models;
using Magicodes.ExporterAndImporter.Excel;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZhonTai.Industry.Services.WorkOrder.Dto.Input
{
    /// <summary>
    /// 字典导入列头筛选器
    /// </summary>
    public class WorkOrderImportHeaderFilter : IImportHeaderFilter
    {
        public List<ImporterHeaderInfo> Filter(List<ImporterHeaderInfo> importerHeaderInfos)
        {
            //foreach (var item in importerHeaderInfos)
            //{
            //    if (item.PropertyName == "Description")
            //    {
            //        item.MappingValues = new Dictionary<string, dynamic>()
            //        {
            //            {"是", true },
            //            {"否", false }
            //        };
            //    }
            //}
            return importerHeaderInfos;
        }
    }

    /// <summary>
    /// 工单导入
    /// </summary>
    [ExcelImporter(IsLabelingError = true, ImportHeaderFilter = typeof(WorkOrderImportHeaderFilter))]
    public class WorkOrderImport
    {
        /// <summary>
        /// ID
        /// </summary>
        [ImporterHeader(Name = "订单Id", IsIgnore = true)]
        public long Id { get; set; }

        /// <summary>
        /// 工单编号
        /// </summary>
        /// <remarks>订单编号</remarks>
        [ImporterHeader(Name = "工单编号", IsAllowRepeat = false)]
        public string OrderCode { get; set; }

        /// <summary>
        /// 工单名称
        /// </summary>
        /// <remarks>工单名称</remarks>
        [ImporterHeader(Name = "工单名称")]
        [MaxLength(40, ErrorMessage = "最大长度不能超过40")]
        public string? OrderName { get; set; }

        /// <summary>
        /// 产品编码
        /// </summary>
        /// <remarks>产品编码</remarks>
        [ImporterHeader(Name = "产品编码")]
        public string? ProductCode { get; set; }

        /// <summary>
        /// 产品名称
        /// </summary>
        /// <remarks>产品名称</remarks>
        [ImporterHeader(Name = "产品名称")]
        public string? ProductName { get; set; }

        /// <summary>
        /// 计划数量
        /// </summary>
        /// <remarks>计划数量</remarks>
        [ImporterHeader(Name = "计划数量")]
        public int PlanCount { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        /// <remarks>排序</remarks>
        [ImporterHeader(Name = "排序")]
        public int Sort { get; set; }

        /// <summary>
        /// 计划开始时间
        /// </summary>
        /// <remarks>计划开始时间</remarks>
        [ImporterHeader(Name = "计划开始时间")]
        public DateTime PlanStartDate { get; set; }

        /// <summary>
        /// 计划结束时间
        /// </summary>
        /// <remarks>计划结束时间</remarks>
        [ImporterHeader(Name = "计划结束时间")]
        public DateTime PlanEndDate { get; set; }

        /// <summary>
        /// 描述
        /// </summary>
        [ImporterHeader(Name = "描述")]
        public string Description { get; set; }
    }
}